package com.rd.student.ruanjian.class3.gaochenxi.LianXi3.NumberFour;

public class NumberFour {
   public static void main(String[] args) {
      Cave cave = new Cave();
      Thread t1 = new Thread(cave, "1");
      Thread t2 = new Thread(cave, "2");
      Thread t3 = new Thread(cave, "3");
      Thread t4 = new Thread(cave, "4");
      Thread t5 = new Thread(cave, "5");
      Thread t6 = new Thread(cave, "6");
      Thread t7 = new Thread(cave, "7");
      Thread t8 = new Thread(cave, "8");
      Thread t9 = new Thread(cave, "9");
      Thread t10 = new Thread(cave, "10");

      t1.start();
      t2.start();
      t3.start();
      t4.start();
      t5.start();
      t6.start();
      t7.start();
      t8.start();
      t9.start();
      t10.start();
   }
}

class Cave extends Thread {
   @Override
   public void run() {
      synchronized (this) {
         System.out.println(Thread.currentThread().getName() + "正在通过洞穴，请等待...");
         Cave cave = new Cave();
         Thread thread = new Thread(cave);
         try {
            Thread.sleep(1000);
         } catch (Exception e) {
            e.printStackTrace();
         }
      }
   }
}
